const { defineConfig } = require("@vue/cli-service");
const { VantResolver } = require('unplugin-vue-components/resolvers');
const ComponentsPlugin = require('unplugin-vue-components/webpack');
const path = require('path')
module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave:false,

  //  跨域问题:  同源策略的问题,  用服务器去访问服务器 
  configureWebpack: {
    plugins: [
      ComponentsPlugin({
        resolvers: [VantResolver()],
      }),
    ],
    resolve: {
      alias: {
        // @指向src目录
        "@": path.join(__dirname, "src"),
        //配置api目录
        "@api": path.join(__dirname, "src/api"),
        //配置util目录
        "@util": path.join(__dirname, "src/util"),
        "@com": path.join(__dirname, "src/components"),
      },
      // 可以忽略以下扩展名，会按照顺序依次匹配
      extensions: [".js", ".json", ".vue"],
    },
  },
    devServer: {
      proxy: {
        '/dev': {
          target: 'http://127.0.0.1:3300',
          pathRewrite: { 
            '^/dev': '' 
          },
          changeOrigin: true,
        },
      },
      // onbefor : ()=>{  }
      onBeforeSetupMiddleware:require('./mock')
    },


});
